package com.rpay.common.exception;

import com.rpay.common.enums.PcsResultCode;


/**
 * Title：
 * Description
 * 系统业务异常.
 * 不直接使用PcsRuntimeException,应该使用 PcsRunTimeException 的子类抛出来区分业务错误类型
 *
 * @author fxg06 on 2018/4/18
 * @version 1.0
 */
public class PcsRunTimeException extends RuntimeException {
    /**
     * Default UID.
     */
    private static final long serialVersionUID = 3306270148021281526L;

    /**
     * The error code.
     */
    private Integer errorCode = PcsResultCode.SUCCESS.getCode();

    /**
     * The error.
     */
    private PcsResultCode error = PcsResultCode.SUCCESS;

    /**
     * 传输的数据
     */
    private Object data;

    /**
     * Instantiates a new pcs run time exception.
     *
     * @param code the code
     */
    protected PcsRunTimeException(PcsResultCode code) {
        super(code.getDesc());
        this.errorCode = code.getCode();
        this.error = code;
    }


    /**
     * Instantiates a new pcs run time exception.
     *
     * @param code    the code
     * @param message the message
     */
    protected PcsRunTimeException(PcsResultCode code, String message) {
        super(message);
        this.errorCode = code.getCode();
        this.error = code;
    }


    /**
     * 重写fillInStackTrace 方法, 不打印堆栈信息,提高性能
     *
     * @return
     */
    @Override
    public synchronized Throwable fillInStackTrace() {
        return this;
    }


    public Integer getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public PcsResultCode getError() {
        return error;
    }

    public void setError(PcsResultCode error) {
        this.error = error;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
